<?php
  if(isset($_GET["id"]) == false)
    DataProvider::ExecuteQuery('index.php?b=4');

  $id = $_GET['id'];
  $sql = "SELECT * FROM sach WHERE MaSach = $id";
  $result = DataProvider::ExecuteQuery($sql);
  $row = mysql_fetch_array($result);
?>


<div class="span11">
    <form name="RegisterForm" method="post" action="pages/pExSuaSach.php?act=do&id=<?php echo $row["MaSach"] ?>" id="RegisterForm" class="form-horizontal" enctype="multipart/form-data">
    <div class="head">
        <div class="isw-documents"></div>
        <h1>Cập Nhật Thông Tin Sách "<?php echo $row['TenSach']; ?>"</h1>
        <div class="clear"></div>
    </div>
    <div class="block-fluid">
        <div class="row-form">
            <div class="span11">Ảnh Bìa Sách: Cũ là: <img src="../<?php echo $row["HinhURL"]; ?>" class="img-polaroid"></div>

            <div class="span11">
                <input type="file" name="file" />
            </div>
            <div class="clear"></div>
        </div>

        <div class="row-form">
            <div class="span3">Tên Sách (Cũ là: <?php echo $row['TenSach']; ?>): </div>
            <div class="span9"><input name="txttensach" type="text" id="txttensach" placeholder="Tên Sách"></div>
            <div class="clear"></div>
        </div>

        <div class="row-form">
            <div class="span3">Tác Giả (Cũ là: <?php echo $row['TacGia']; ?>): </div>
            <div class="span9"><input name="txttacgia" type="text" id="txttacgia" placeholder="Tên Tác Giả"></div>
            <div class="clear"></div>
        </div>
        <div class="row-form">
            <div class="span3">Loại Sách: (Cũ là:
                <?php
                    $ma = $row['MaLoaiSach'];

                    $sql2 = "SELECT * FROM loaisach WHERE MaLoaiSach = '$ma'";
                    $result2 = DataProvider::ExecuteQuery($sql2);
                    $row2 = mysql_fetch_array($result2);

                    echo $row2["TenLoaiSach"];

                ?>
                )

            </div>
            <div class="span2">
                <select name="oploaisach" id="oploaisach">
                        <option value="">Loại Sách...</option>
                        <?php

                            $sql3 = "SELECT * FROM loaisach WHERE Bixoa=0";
                            $result3 = DataProvider::ExecuteQuery($sql3);

                            while($row3 = mysql_fetch_array($result3))
                                {
                        ?>
                        <option value="<?php echo $row3['MaLoaiSach']; ?>"><?php echo $row3['TenLoaiSach']; ?></option>


                        <?php
                            }
                        ?>


                </select>
            </div>
            <div class="clear"></div>
        </div>
        <div class="row-form">
            <div class="span3">Chi Tiết Loại Sách: (Cũ là:
                <?php
                    $ma2 = $row['MaChiTietLoaiSach'];

                    $sql5 = "SELECT * FROM chitietloaisach WHERE MaChiTietLoaiSach = '$ma2'";
                    $result5 = DataProvider::ExecuteQuery($sql5);
                    $row5 = mysql_fetch_array($result5);

                    echo $row5["TenChiTietLoaiSach"];

                ?>
                )

            </div>
            <div class="span2">
                <select name="opchitietloaisach" id="opchitietloaisach">
                        <option value="">Chi Tiết Loại Sách...</option>
                        <?php

                            $sql4 = "SELECT * FROM chitietloaisach WHERE Bixoa=0";
                            $result4 = DataProvider::ExecuteQuery($sql4);

                            while($row4 = mysql_fetch_array($result4))
                                {
                        ?>
                        <option value="<?php echo $row4['MaChiTietLoaiSach']; ?>"><?php echo $row4['TenChiTietLoaiSach']; ?></option>


                        <?php
                            }
                        ?>


                </select>
            </div>
            <div class="clear"></div>
        </div>
        <div class="row-form">
            <div class="span3">Nhà Xuất Bản: (Cũ là:
                <?php
                    $ma3 = $row["MaNXB"];

                    $sql6 = "SELECT * FROM nxb WHERE MaNXB='$ma3'";
                    $result6 = DataProvider::ExecuteQuery($sql6);
                    $row6 = mysql_fetch_array($result6);

                    echo $row6["TenNXB"];

                ?>
                )

            </div>
            <div class="span2">
                <select name="opnxb" id="opnxb">
                        <option value="">Nhà Xuất Bản...</option>
                        <?php

                            $sql7 = "SELECT * FROM nxb WHERE Bixoa=0";
                            $result7 = DataProvider::ExecuteQuery($sql7);

                            while($row7 = mysql_fetch_array($result7))
                                {
                        ?>
                        <option value="<?php echo $row7['MaNXB']; ?>"><?php echo $row7['TenNXB']; ?></option>


                        <?php
                            }
                        ?>


                </select>
            </div>
            <div class="clear"></div>
        </div>
        <div class="row-form">
            <div class="span3">Trạng Thái Sách: (Cũ là:
                <?php
                    $ma4 = $row["MaTrangThaiSach"];

                    $sql8 = "SELECT * FROM trangthaisach WHERE MaTrangThaiSach='$ma4'";
                    $result8 = DataProvider::ExecuteQuery($sql8);
                    $row8 = mysql_fetch_array($result8);

                    echo $row8["TenTrangThaiSach"];

                ?>
                )

            </div>
            <div class="span2">
                <select name="optrangthai" id="optrangthai">
                        <option value="">Trạng Thái Sách...</option>
                        <?php

                            $sql9 = "SELECT * FROM trangthaisach";
                            $result9 = DataProvider::ExecuteQuery($sql9);

                            while($row9 = mysql_fetch_array($result9))
                                {
                        ?>
                        <option value="<?php echo $row9['MaTrangThaiSach']; ?>"><?php echo $row9['TenTrangThaiSach']; ?></option>


                        <?php
                            }
                        ?>


                </select>
            </div>
            <div class="clear"></div>
        </div>

        <div class="row-form">
            <div class="span3">Số Lượng Tồn (Cũ là: <?php echo $row['SoLuongTon']; ?>): </div>
            <div class="span9"><input name="txtslton" type="text" id="txtslton" placeholder="Số Lượng Tồn"></div>
            <div class="clear"></div>
        </div>
        <div class="row-form">
            <div class="span3">Số Lượng Cho Mượn (Cũ là: <?php echo $row['SoLuongChoMuon']; ?>): </div>
            <div class="span9"><input name="txtslchomuon" type="text" id="txtslchomuon" placeholder="Số Lượng Cho Mượn"></div>
            <div class="clear"></div>
        </div>

        <div class="row-form">
            <div class="span12">Mô Tả (Cũ là: <?php echo $row['MoTa']; ?>): </div>
            <div class="span12"><input name="txtmota" type="textarea" id="txtmota" placeholder="Mô Tả Sách" style="width:860px" ></div>
            <div class="clear"></div>
        </div>


        <div class="row-form">
            &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
            <input type="submit" name="btnSubmit" value="Cập nhật" id="btnSubmit" class="btn btn-primary" >

            <input class="btn btn-danger" onclick="location = 'index.php?b=4';" type="button" value="Quay Lại">
        </div>

    </div>
    </form>
</div>